<template>
  <div>
    <!-- <h3 class="title">搜索页面</h3> -->
    <to-back></to-back>
    <!-- <div class="sousuo">
      <input type="text" placeholder="请输入很关键词" autofocus v-model="kw" @keydown.enter="enter" />
    </div> -->
    <van-search v-model="kw" placeholder="请输入搜索关键词" autofocus  @keydown.enter="enter" />

    <hr />
    <!-- 因为与list的结构一样，所以封装一个全局组件 -->
    <v-list :arr="goods"></v-list>
  </div>
</template>

<script>
// import axios from "axios";
import {reqSearch} from "../../http/http";
export default {
  data() {
    return {
      // 1.初始化空数组
      goods: [],
      // 定义变量
      kw: ""
    };
  },
  methods: {
    enter() {
      //按下回车 发请求
      reqSearch({
        keywords: this.kw
      }).then(res => {
        console.log(res);
        this.goods = res.data.list ? res.data.list : [];
      });
    }
  }
};
</script>

<style scoped>
.item {
  padding: 0.1rem;
  margin: 0.1rem;
  border: 0.01rem solid #ccc;
}
a {
  margin: 0.1rem;
  display: inline-block;
}
.sousuo {
  padding: 10px;
}
</style>